<template>
    <!-- 遮罩层 -->
    <transition name="fade">
      <div v-if="visible" class="overlay" @click="closeModal"></div>
    </transition>
  
    <!-- 弹窗 -->
    <transition name="slide">
      <div v-if="visible" class="modal">
        <div class="modal-title">
          <img src="../assets/me_home/dingweimao.png" alt="">
          <div class="title-text">{{ bianObj.obj?.name }}</div>
          <span class="close-btn" @click="closeModal">&times;</span>
        </div>
        <div class="modal-con">
          <div class="con-item" @click="openBianZhan(bianObj)" style="cursor: pointer;">
            <img src="../assets/me_home/guizi.png" alt="" style="width: 94px;height: 85px;">
            <div class="nameBox">
              <div class="name">变电站名称：工厂变电站</div>
              <div class="name">变电柜数量：12</div>
              <div class="number">安装时间：{{ bianObj.time }}</div>
            </div>
          </div>
          <div class="con-item" @click="openBianZhan(bianObj)" style="cursor: pointer;">
            <img src="../assets/me_home/guizi.png" alt="" style="width: 94px;height: 85px;">
            <div class="nameBox">
              <div class="name">变电站名称：测试变电站</div>
              <div class="name">变电柜数量：5</div>
              <div class="number">安装时间：2025-01-21 10:53Am</div>
            </div>
          </div>
        </div>
      </div>
    </transition>
  </template>
  
  <script setup>
  import { defineProps, defineEmits } from 'vue';
  
  // 定义 props
  const props = defineProps({
    visible: {
      type: Boolean,
      default: false,
    },
    bianObj: {
      type: Object,
      default: {}
    }
  });
  
  // 跳转ue模型关卡
  const openBianZhan = (obj) => {
    ue5("openBianZhan", obj.title)
    console.log("=====>", obj)
  }
  
  // 定义 emits
  const emit = defineEmits(['update:visible']);
  
  // 关闭弹窗
  const closeModal = () => {
    emit('update:visible', false);
  };
  </script>
  
  <style scoped lang="scss">
  /* 遮罩层动画 */
  .fade-enter-active,
  .fade-leave-active {
    transition: opacity 0.3s ease;
  }
  
  .fade-enter-from,
  .fade-leave-to {
    opacity: 0;
  }
  
  /* 弹窗动画 */
  .slide-enter-active,
  .slide-leave-active {
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  
  .slide-enter-from,
  .slide-leave-to {
    transform: translateX(100%);
    opacity: 0;
  }
  
  /* 遮罩层 */
  .overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    z-index: 999;
  }
  
  /* 弹窗 */
  .modal {
    position: fixed;
    top: 100px;
    right: 20px;
    width: 400px;
    padding: 20px;
    background: #000000;
    border: 1px solid #565454;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
  }
  
  .modal-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #323332;
    padding: 10px 20px;
    box-sizing: border-box;
  
    img {
      width: 35px;
      height: 35px;
    }
  
    .title-text {
      margin-left: 10px;
      font-size: 16px;
      width: 300px;
    }
  }
  
  .modal-con {
    background-color: #202121;
    width: 100%;
  
    .con-item {
      border-bottom: 1px solid #585757;
      width: 100%;
      height: 150px;
      display: flex;
      align-items: center;
      justify-content: space-around;
  
      .nameBox {
        padding-top: 20px;
        width: 250px;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
  
        .name {
          width: 100%;
          color: #c9cdcd;
          font-size: 18px;
          margin-top: 5px;
        }
  
        .number {
          width: 100%;
          height: 60px;
          font-size: 16px;
          margin-top: 5px;
        }
      }
    }
  }
  
  /* 关闭按钮 */
  .close-btn {
    float: left;
    cursor: pointer;
    font-size: 26px;
    font-weight: bold;
  }
  </style>